<template>
	<view>
		<view class="listbox" v-for="(item,index) in list" :key="index" @click="topage(item)">
			<view class="namebox">{{item.course_name}}</view>
			<view class="sepcbox">
				<view class="type">报名截止时间</view>
				<view class="time">{{dateFormat(item.sign_end_time)}}   共{{item.class_hour}}课时</view>
			</view>
			<view class="infobox">
				<view class="teachername">
					<image :src="item.teacher_avator"></image>
					<view>老师:{{item.teacher_name}}</view>
				</view>
				<view class="butbox">
					点击报名
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name:"classlist",
		props:{
			list:{
				type:Array,
				default:[]
			}
		},
		data() {
			return {
				
			};
		},
		methods:{
			dateFormat: function(value) {           
				var date = new Date(value*1000); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
				var year = date.getFullYear();
				var month = ("0" + (date.getMonth() + 1)).slice(-2);
				var sdate = ("0" + date.getDate()).slice(-2);
				var hour = ("0" + date.getHours()).slice(-2);
				var minute = ("0" + date.getMinutes()).slice(-2);
				var second = ("0" + date.getSeconds()).slice(-2);
				// 拼接
				var result = year + "年" + month + "月" + sdate + "日 " + hour + ":" + minute //+ ":" + second;
				// 返回
				return result;
			},
			topage(item){
				uni.navigateTo({
					url:'/pages/coursesinfo/coursesinfo?id='+item.id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.listbox{
		width: 642rpx;
		margin: 0rpx auto 18rpx auto;
		padding: 40rpx 24rpx;
		background: #FFFFFF;
		box-shadow: inset 0rpx 4rpx 8rpx 2rpx rgba(245,165,40,0.4);
		border-radius: 20rpx;
		.namebox{
			font-size: 36rpx;
			font-family: Source Han Sans CN-Medium, Source Han Sans CN;
			font-weight: 500;
			color: #222222;
		}
		.sepcbox{
			display: flex;
			align-items: center;
			margin: 30rpx 0;
			.type{
				width: 68rpx;
				height: 38rpx;
				background: linear-gradient(180deg, #FCBB8C 0%, #FF8158 100%);
				border-radius: 4rpx 8rpx 8rpx 8rpx;
				font-size: 28rpx;
				font-family: Source Han Sans CN-Medium, Source Han Sans CN;
				font-weight: 500;
				color: #FFFFFF;
				text-align: center;
				line-height: 38rpx;
				margin-right: 18rpx;
			}
			.time{
				font-size: 28rpx;
				font-family: Source Han Sans CN-Regular, Source Han Sans CN;
				font-weight: 400;
				color: #555555;
			}
		}
		.infobox{
			display: flex;
			align-items: center;
			justify-content: space-between;
			.teachername{
				display: flex;
				align-items: center;
				font-size: 28rpx;
				font-family: Source Han Sans CN-Medium, Source Han Sans CN;
				font-weight: 500;
				color: #555555;
				
				image{
					width: 54rpx;
					height: 54rpx;
					border-radius: 100%;
					margin-right: 18rpx;
				}
				>view{
					width: 360rpx;
					-webkit-line-clamp: 1;
					display: -webkit-box;
					-webkit-box-orient: vertical;
					overflow: hidden;
					text-overflow: ellipsis;
				}
			}
			.butbox{
				width: 210rpx;
				height: 60rpx;
				background: #FF8A9B;
				border-radius: 32rpx ;
				line-height: 60rpx;
				text-align: center;
				font-size: 32rpx;
				font-family: Source Han Sans CN-Medium, Source Han Sans CN;
				font-weight: 500;
				color: #FFFFFF;
			}
		}
	}

</style>